
local style_btn         = nil
local style_btn_pressed = nil
local style_btn_red     = nil

local function darken( dsc, color, opa )

	return lv.color_darken( color, opa );
end

local function style_init()

	style_btn = lv.create_style();

	lv.style_set_radius( style_btn, 10 );

	lv.style_set_bg_opa( style_btn, lv.LV_OPA_COVER );

	lv.style_set_bg_color( style_btn, lv.palette_lighten( lv.LV_PALETTE_GREY, 3 ) );

	lv.style_set_bg_grad_color( style_btn, lv.palette_main( lv.LV_PALETTE_GREY ) );

	lv.style_set_bg_grad_dir( style_btn, lv.LV_GRAD_DIR_VER );

	lv.style_set_border_color( style_btn, lv.color_black() );

	lv.style_set_border_opa( style_btn, lv.LV_OPA_20 );

	lv.style_set_border_width( style_btn, 2 );

	lv.style_set_text_color( style_btn, lv.color_black() );


	color_filter = lv.create_color_filter_dsc( darken );

	style_btn_pressed = lv.create_style();

	lv.style_set_color_filter_dsc( style_btn_pressed, color_filter );

	lv.style_set_color_filter_opa( style_btn_pressed, lv.LV_OPA_20 );
	
	

	style_btn_red = lv.create_style();
	
	lv.style_set_bg_color( style_btn_red, lv.palette_main( lv.LV_PALETTE_RED ) );
	
	lv.style_set_bg_grad_color( style_btn_red, lv.palette_lighten( lv.LV_PALETTE_RED, 3 ) );
end

style_init()

local btn = lv.btn_create( lv.scr_act() );

lv.obj_remove_style_all( btn );

lv.obj_set_pos( btn, 10, 10 );

lv.obj_set_size( btn, 120, 50 );

lv.obj_add_style( btn, style_btn, 0 );

lv.obj_add_style( btn, style_btn_pressed, lv.LV_STATE_PRESSED );

local label = lv.label_create( btn );

lv.label_set_text( label, "Button" );

lv.obj_center( label );


local btn2 = lv.btn_create( lv.scr_act() );

lv.obj_remove_style_all( btn2 );

lv.obj_set_pos( btn2, 10, 80 );

lv.obj_set_size( btn2, 120, 50 );

lv.obj_add_style( btn2, style_btn, 0 );

lv.obj_add_style( btn2, style_btn_red, 0 );

lv.obj_add_style( btn2, style_btn_pressed, lv.LV_STATE_PRESSED );

lv.obj_set_style_radius( btn2, lv.LV_RADIUS_CIRCLE, 0 );

label = lv.label_create( btn2 );

lv.label_set_text( label, "Button 2" );

lv.obj_center( label );
